package org.bridgen.runtime.model;

import org.bridgen.runtime.util.Interval;

/**
 * 
 * @author Emma Söderberg <emma add cs.lth.se>
 *
 */

public abstract class Reef extends LexicalNode {
	public Reef(LexicalNode previous, Interval interval, String value) {
		super(previous, interval, value);
	}
	
	public void mergeWith(Reef node) {
		if (node == getNext()) {
			this.value += node.value;
			this.interval.mergeWith(node.interval);
			LexicalNode next = node.getNext();
			this.setNext(next);
			if (next != null) {
				next.setPrevious(this);
			}
		} else {
			throw new Error("Can only merge to consecutive Layout nodes");
		}
	}

}
